

<template>

  <div >
       <el-button  class="butB_Sel"  @click="printBtn()">打印</el-button>
	 <el-col :span='8'>
	  <el-form label-position="right" label-width="100px" :model="patientinfo">
  <el-form-item label="是否残联">
         <el-checkbox v-model="is_can"></el-checkbox>
  </el-form-item>
   <el-form-item label="补理疗费">
         <el-checkbox v-model="is_liliao"></el-checkbox>
  </el-form-item>
    <el-form-item label="补生活费/调温费">
         <el-checkbox v-model="is_shenghuofei"></el-checkbox>
  </el-form-item>
    
  <el-form-item label="理疗费">
         <el-input v-model="liliao"></el-input>
  </el-form-item>
   <el-form-item label="生活费">
         <el-input v-model="shenghuofei"></el-input>
  </el-form-item>
   <el-form-item label="调温费">
         <el-input v-model="tiaowen"></el-input>
  </el-form-item>
 </el-form >
	  </el-col>

    <div  class="app-container" id="printcons" style="width:600px;height:420px;margin:auto;position: relative">
      <div v-show="!is_shenghuofei" class="" style="padding-top:22px;">
   

  									<h2 style="text-align: center;margin: 0 5px;opacity: 0;">{{tabeldata.his_name}}</h2>
						             <h3  style="text-align: center;margin: 0 5px;width:500px;float: right;">  <span v-if="is_can" style="float: right;margin: 0 0.3125rem;font-size: 16px;"> 残联</span> 
									 </h3>
									 <span v-show='is_liliao' style='position: absolute;bottom: 185px;right: 150px;font-size:12px'> 理疗费:{{liliao}}  </span>
									 <!-- <span v-show='is_shenghuofei' style='position: absolute;bottom: 185px;right: 150px;'> 生活费:{{shenghuofei}}  </span> -->
												<p style="margin: 0 0.3125rem;font-size: 12px;	">
												<span style="float: right;margin: 0 0.3125rem;font-size: 11px;">  </span>
												</p>
												<!-- <p  style="margin: 0 0;font-size: 18px;opacity: 0;">发票代码：xxxxxxx</p> -->
												<!-- <p style="margin: 0 0;font-size: 13px;opacity: 0;">发票号码：xxxxxxx -->
												<!-- </p> -->
                                              
												<h4   v-show='!is_liliao' style="margin: 5px 5px;padding-left:10px"><span style="opacity: 0;"> 医院名称:</span>{{tabeldata.his_name}} <span style="margin-left:100px;">{{tabeldata.setl_time}}</span></h4>
												<table  v-show='!is_liliao'   cellspacing="0" cellpadding="0" style="width:576px">
												   <tr>
												    <td style=" width:72px; height:20px;" ><span style="opacity: 0;">姓名</span> </td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.member.name}}</td>
												    <td style=" width:72px; height:20px;" ><span style="opacity: 0;">性别</span></td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.member.gender==1?'男':tabeldata.hospital_info.member.gender==2?'女':''}}</td>
													 <td style=" width:72px; height:20px;" ><span style="opacity: 0;">住院号</span></td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.ipt_no}}</td>
												    <td style=" width:72px; height:20px;" ><span style="opacity: 0;">病区</span></td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.room_name.split('/')[1]}}</td>
												   </tr>
												   <tr>
												     <td style="height:20px;" > <span style="opacity: 0;">医保卡号</span></td>
												     <td>{{tabeldata.insutype}}</td>
												     <td style=" height:20px;" > <span style="opacity: 0;">住院时间</span></td>
													<!-- <td colspan="5">{{tabeldata.hospital_info.begntime}}-{{tabeldata.hospital_info.leave_time}} <span style="margin-left:130px">{{tabeldata.hospital_info.day}}</span></td> -->
													<td colspan="5" class="spans"><span style="display: inline-block;width: 40px;" >{{begntimy[0]}}</span>
													<span style="display: inline-block;width: 50px;">{{begntimy[1]}}</span><span style="display: inline-block;width: 50px;">{{begntimy[2]}}</span> <span style="display: inline-block;width: 40px;"> {{leave_timey[0]}}</span>  <span style="display: inline-block;width: 50px;"> {{leave_timey[1]}}</span>  <span style="display: inline-block;width: 40px;"> {{leave_timey[2]}}</span> <span style="margin-left:10px">{{tabeldata.hospital_info.day}}</span></td>

													  
												   </tr>
												    <tr>
												     <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
												      <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
													     <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
													     <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
												     </tr>
													<tr>
												     <td style="height:20px;" ><span style="opacity: 0;">床位费</span></td>
												     <td>{{tabeldata.fee[10].money}}</td>
												     <td style=" height:20px;" ><span style="opacity: 0;">化验费</span></td>
												     <td>{{tabeldata.fee[0].money}}</td>
													 <td style="height:20px;" ><span style="opacity: 0;">西药费</span></td>
												     <td>{{tabeldata.fee[8].money}}</td>
												     <td style="height:20px;" ><span style="opacity: 0;">特殊材料费</span></td>
												     <td>{{tabeldata.fee[4].money}}</td>
												     </tr>
													   <tr>
												     <td style=" height:20px;" >
														 <span style="opacity: 0;">诊查费</span>
														 </td>
												     <td>{{tabeldata.fee[2].money}}</td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">治疗费</span>
														 </td>
	
												     <td>{{tabeldata.fee[13].money}}</td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">中成药</span>
														 </td>
													 
												     <td>{{tabeldata.fee[9].money}}</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">特殊服务</span>
														 </td>
												    
												     <td>{{tabeldata.amount}}</td>
												     </tr>
													   <tr>
														     <td style=" height:20px;" >
														 <span style="opacity: 0;">护理费</span>
														 </td>
												     
												     <td>{{tabeldata.fee[11].money}}</td>
													 <td style=" height:20px;" >
														 <span style="opacity: 0;">手术费</span>
														 </td>
												  
												     <td>{{tabeldata.fee[3].money}}</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">中草药</span>
														 </td>
													
												     <td>{{tabeldata.fee[12].money}}</td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">其他</span>
														 </td>
												
												     <td>{{tabeldata.fee[6].money}}</td>
												     </tr>
													   <tr>
														    <td style=" height:20px;" >
														 <span style="opacity: 0;">检查费</span>
														 </td>
												
												 
												     <td>{{tabeldata.fee[1].money}}</td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">电费</span>
														 </td>
												    
												     <td>0</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">调温费</span>
														 </td>
												
												     <td>0</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">合计</span>
														 </td>
												  
												     <td>{{tabeldata.cost}}</td>
												     </tr>
													   <tr>
												     <td colspan="2" style="opacity: 0;height:20px;padding-top:5px">总金额（大写）</td>
												    
												     <td colspan="5" style=" height:20px;">
														 {{tabeldata.dx_cost}}
													 </td>
												    
												     </tr>
													   <tr style="padding-top:5px">
														     <td style=" height:20px;" >
														 <span style="opacity: 0;">预交费用</span>
														 </td>
												   		<td>{{tabeldata.wallet_income}}</td>
												     <td style=" height:20px;">0</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">现金退款</span>
														 </td>
												  
												     <td></td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">支票退费</span>
														 </td>
													
												     <td>0</td>
													 	  <td style=" height:20px;" >
														 <span style="opacity: 0;">应补金额</span>
														 </td>
												  
												     <td></td>
												     </tr>
													   <tr style="padding-top:5px">
												     <td rowspan="2" style="opacity: 0;">备注</td>
												     <td rowspan="2" colspan="7" style=" height:40px;">
													
														 <p > 
													
														 
														 
														 <span style="float:left;margin-left:290px">{{psn_part_amt}}</span>
														 <span style="float:right;margin-right:40px">{{fund_pay_sumamt}}</span>
														   </p>
													 </td>
												    
												     </tr>
												
												</table>
												<!-- <p style="opacity: 0;">开票人</p> -->
												
												<p style="margin: 0rem;" v-show='!is_liliao'   ><span style="margin-left:120px;">{{tabeldata.create_by}}</span></p>

		        </div>

				<div v-show="is_shenghuofei" class="" style="padding-top:22px;">
   

  									<h2 style="text-align: center;margin: 0 5px;opacity: 0;">{{tabeldata.his_name}}</h2>
						             <h3  style="text-align: center;margin: 0 5px;width:500px;float: right;">  <span v-if="is_can" style="float: right;margin: 0 0.3125rem;font-size: 16px;"> 残联</span> 
									 </h3>
									 <!-- <span  style='position: absolute;bottom: 168px;right: 140px;'> 生活费:{{shenghuofei}}  </span> -->
												<p style="margin: 0 0.3125rem;font-size: 12px;	">
												<span style="float: right;margin: 0 0.3125rem;font-size: 11px;">  </span>
												</p>
												<!-- <p  style="margin: 0 0;font-size: 18px;opacity: 0;">发票代码：xxxxxxx</p> -->
												<!-- <p style="margin: 0 0;font-size: 13px;opacity: 0;">发票号码：xxxxxxx -->
												<!-- </p> -->
                                              
												<h4   v-show='!is_liliao' style="margin: 5px 5px;padding-left:10px"><span style="opacity: 0;"> 医院名称:</span>{{tabeldata.his_name}} <span style="margin-left:100px;">{{tabeldata.setl_time}}</span></h4>
												<table  v-show='!is_liliao'   cellspacing="0" cellpadding="0" style="width:576px">
												   <tr>
												    <td style=" width:72px; height:20px;" ><span style="opacity: 0;">姓名</span> </td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.member.name}}</td>
												    <td style=" width:72px; height:20px;" ><span style="opacity: 0;">性别</span></td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.member.gender==1?'男':tabeldata.hospital_info.member.gender==2?'女':''}}</td>
													 <td style=" width:72px; height:20px;" ><span style="opacity: 0;">住院号</span></td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.ipt_no}}</td>
												    <td style=" width:72px; height:20px;" ><span style="opacity: 0;">病区</span></td>
												    <td style=" width:72px;height:20px;">{{tabeldata.hospital_info.room_name.split('/')[1]}}</td>
												   </tr>
												   <tr>
												     <td style="height:20px;" > <span style="opacity: 0;">医保卡号</span></td>
												     <td>{{tabeldata.insutype}}</td>
												     <td style=" height:20px;" > <span style="opacity: 0;">住院时间</span></td>
													<!-- <td colspan="5">{{tabeldata.hospital_info.begntime}}-{{tabeldata.hospital_info.leave_time}} <span style="margin-left:130px">{{tabeldata.hospital_info.day}}</span></td> -->
													<td colspan="5" class="spans"><span style="display: inline-block;width: 40px;" >{{begntimy[0]}}</span>
													<span style="display: inline-block;width: 50px;">{{begntimy[1]}}</span><span style="display: inline-block;width: 50px;">{{begntimy[2]}}</span> <span style="display: inline-block;width: 40px;"> {{leave_timey[0]}}</span>  <span style="display: inline-block;width: 50px;"> {{leave_timey[1]}}</span>  <span style="display: inline-block;width: 40px;"> {{leave_timey[2]}}</span> <span style="margin-left:10px">{{tabeldata.hospital_info.day}}</span></td>

													  
												   </tr>
												    <tr>
												     <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
												      <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
													     <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
													     <td style=" height:20px;" ><span style="opacity: 0;">费用项目</span> </td>
												     <td style=" height:20px;" ><span style="opacity: 0;">金额</span></td>
												     </tr>
													<tr>
												     <td style="height:20px;" ><span style="opacity: 0;">床位费</span></td>
												     <td></td>
												     <td style=" height:20px;" ><span style="opacity: 0;">化验费</span></td>
												     <td></td>
													 <td style="height:20px;" ><span style="opacity: 0;">西药费</span></td>
												     <td></td>
												     <td style="height:20px;" ><span style="opacity: 0;">特殊材料费</span></td>
												     <td></td>
												     </tr>
													   <tr>
												     <td style=" height:20px;" >
														 <span style="opacity: 0;">诊查费</span>
														 </td>
												     <td></td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">治疗费</span>
														 </td>
	
												     <td></td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">中成药</span>
														 </td>
													 
												     <td></td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">特殊服务</span>
														 </td>
												    
												     <td>{{tabeldata.amount}}</td>
												     </tr>
													   <tr>
														     <td style=" height:20px;" >
														 <span style="opacity: 0;">护理费</span>
														 </td>
												     
												     <td></td>
													 <td style=" height:20px;" >
														 <span style="opacity: 0;">手术费</span>
														 </td>
												  
												     <td></td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">中草药</span>
														 </td>
													
												     <td></td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">其他</span>
														 </td>
												
												     <td>{{shenghuofei}}</td>
												     </tr>
													   <tr>
														    <td style=" height:20px;" >
														 <span style="opacity: 0;">检查费</span>
														 </td>
												
												 
												     <td></td>
													   <td style=" height:20px;" >
														 <span style="opacity: 0;">电费</span>
														 </td>
												    
												     <td>0</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">调温费</span>
														 </td>
												
												     <td>{{tiaowen}}</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">合计</span>
														 </td>
												  
												     <td>{{bxy_total}}</td>
												     </tr>
													   <tr>
												     <td colspan="2" style="opacity: 0;height:20px;padding-top:5px">总金额（大写）</td>
												    
												     <td colspan="5" style=" height:20px;">
														{{AmountLtoU(bxy_total)}}
													 </td>
												    
												     </tr>
													   <tr style="padding-top:5px">
														     <td style=" height:20px;" >
														 <span style="opacity: 0;">预交费用</span>
														 </td>
												   		<td></td>
												     <td style=" height:20px;">0</td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">现金退款</span>
														 </td>
												  
												     <td></td>
													  <td style=" height:20px;" >
														 <span style="opacity: 0;">支票退费</span>
														 </td>
													
												     <td>0</td>
													 	  <td style=" height:20px;" >
														 <span style="opacity: 0;">应补金额</span>
														 </td>
												  
												     <td></td>
												     </tr>
													   <tr style="padding-top:5px">
												     <td rowspan="2" style="opacity: 0;">备注</td>
												     <td rowspan="2" colspan="7" style=" height:40px;">
													
														 <p > 
													
														 
														 
														 <span style="float:left;margin-left:290px"></span>
														 <span style="float:right;margin-right:40px"></span>
														   </p>
													 </td>
												    
												     </tr>
												
												</table>
												<!-- <p style="opacity: 0;">开票人</p> -->
												
												<p style="margin: 0rem;"  ><span style="margin-left:120px;">{{tabeldata.create_by}}</span></p>

		        </div>
    </div>
  </div>
</template>
<script>

import { getPrintInvoice,getdictIndex } from "@/api/register";

import { printSettlement } from "@/api/zhuyanre";
 import print from 'print-js'
 let t;
export default {
	props:['id'],
  data() {
    return {
  tabeldata:{},
  sourcelist:[],
   dayin:false,
   psn_part_amt:0,
fund_pay_sumamt:0,
is_can:false,
is_liliao:false,
is_shenghuofei:false,
is_tiaowen:false,
begntimy:['','',''],
leave_timey:['','',''],
liliao:0,
shenghuofei:0,
tiaowen:0,
patientinfo:{},
    };
  },
  
  mounted(){
	t=this;
	console.log(456)
	this.getindex()
   this.getpint()
  },
  computed:{
	bxy_total:()=>{
		console.log("t",t)
		console.log("this",t.shenghuofei+t.tiaowen)
		//return 0
		return (parseFloat(t.shenghuofei)+parseFloat(t.tiaowen))
	},

  },
    watch: {
		// shenghuofei(e){
		// 	this.bxy_total;
		// },
    id(n) {
		console.log(this.id)
			 this.getpinbegntimyt()
	}},
  methods: {
	  	  getindex(){
		  	getdictIndex({group_id:'40'}).then(res=>{
				let data = res.data;
				  data.forEach((item, key) => {
				if(item.id==40){
            
             this.sourcelist=item.items;
            } 
			 })
			  })
	  },
	  	  getpint(){
		  	    printSettlement({hospital_id:this.id}).then(res=>{
                            if(res.code==200){
								console.log(res.data)
                               this.tabeldata=res.data
							//     this.tabeldata.zongfee=0
							//    for (let i = 0; i < this.tabeldata.fee.length; i++) {
							// 	   this.tabeldata.zongfee+=parseInt(this.tabeldata.fee[i].money) 
								   
							//    }
							this.begntimy= this.tabeldata.hospital_info.begntime.split('-')
							this.leave_timey=this.tabeldata.hospital_info.leave_time.split('-')
						console.log(this.tabeldata.yb)
							if(this.tabeldata.yb){
									  this.psn_part_amt=this.tabeldata.yb.psn_part_amt,
									this.fund_pay_sumamt=this.tabeldata.yb.fund_pay_sumamt
							}
							
							}
                    })
	  },
	   AmountLtoU(num) {
      ///<summery>小写金额转化大写金额</summery>
      ///<param name=num type=number>金额</param>
      if (isNaN(num)) return "";
      var strPrefix = "";
      if (num < 0) strPrefix = "(负)";
      num = Math.abs(num);
      if (num >= 1000000000000) return "无效数值！";
      var strOutput = "";
      var strUnit = "仟佰拾亿仟佰拾万仟佰拾元角分";
      var strCapDgt = "零壹贰叁肆伍陆柒捌玖";
      num += "00";
      var intPos = num.indexOf(".");
      if (intPos >= 0) {
        num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
      }
      strUnit = strUnit.substr(strUnit.length - num.length);
      for (var i = 0; i < num.length; i++) {
        strOutput +=
          strCapDgt.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1);
      }
      return (
        strPrefix +
        strOutput
          .replace(/零角零分$/, "整")
          .replace(/零[仟佰拾]/g, "零")
          .replace(/零{2,}/g, "零")
          .replace(/零([亿|万])/g, "$1")
          .replace(/零+元/, "元")
          .replace(/亿零{0,3}万/, "亿")
          .replace(/^元/, "零元")
      );
    },
	  	    mapxing(num) {
      var art = "";
         this.sourcelist.map(function(value,i,array){
            
            if (value.id == num) {
          art = value.name;
        }
        
       })
	   console.log(art)
        return art;  
    },
        printBtn(e) {
        this.dayin=true
         setTimeout(() => {
      this.dayinfun()
     }, 200);
     
    },
        dayinfun(){
             this.remove_ie_header_and_footer();
    //   let subOutputRankPrint = document.getElementById("printcons");
    //   console.log(subOutputRankPrint.innerHTML);
    //   let newContent = subOutputRankPrint.innerHTML;
    //   let oldContent = document.body.innerHTML;
    //   document.body.innerHTML = newContent;
    //   window.print();
    //   window.location.reload();  
	2
    //   document.body.innerHTML = oldContent;
    //   return false;
	const style = '@page {margin:0 10mm};'
	        setTimeout(function() {
        print({
          printable: 'printcons',	//打印区域id
          type: 'html',		//打印类型是html
          scanStyles: false,
		  style,
          targetStyles: ['*'],
        })
      }, 500)
        },
    //去掉页眉和页脚
    remove_ie_header_and_footer() {
      var hkey_path;
      hkey_path =
        "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
      try {
        var RegWsh = new ActiveXObject("WScript.Shell");
        RegWsh.RegWrite(hkey_path + "header", "");
        RegWsh.RegWrite(hkey_path + "footer", "");
      } catch (e) {}
    },

    
    
  },
   
};
</script>
<style media="print">
				@page {
				  size: auto; /* auto is the initial value */
				  margin: 0mm; /* this affects the margin in the printer settings */
				}
				@media print {
				}
				body {
				  -webkit-print-color-adjust: exact;
				}
					#printcons>>>td{
                        height: 25px!important;
                        /* width: 100px; */
						/* border: 0.5px solid #000000; */
						padding: 0rem;
						margin: 0rem;
						text-align: center;
					}
		
				</style>
<style lang='scss' scoped>
// #printcons>>> tr{
// 						height: 20px!important;
// 						padding: 20px 10px;
// 						margin: 0rem;
						
// 					}
//                     	#printcons>>>td{
//                         height: 20px!important;
//                         // width: 100px;
// 						/* border: 0.5px solid #000000; */
// 						padding: 0rem;
// 						margin: 0rem;
// 						text-align: center;
// 					}
		
.spans>span{
	display: inline-block;
	width: 50px;
}

</style>